import request from '@/utils/request'

// 查询课程列表
export function listcourse(query) {
  return request({
    url: '/course/qf/course/list',
    method: 'get',
    params: query
  })
}

// 查询课程详细
export function getRole(roleId) {
  return request({
    url: '/system/role/' + roleId,
    method: 'get'
  })
}

// 新增课程
export function addcourse(data) {
  return request({
    url: '/course/qf/course/',
    method: 'post',
    data: data
  })
}

// 修改课程
export function updateChannel(data) {
  return request({
    url: '/channel/qf/channel/',
    method: 'put',
    data: data
  })
}

// 课程数据权限
export function dataScope(data) {
  return request({
    url: '/system/role/dataScope',
    method: 'put',
    data: data
  })
}

// 课程状态修改
export function changeRoleStatus(roleId, status) {
  const data = {
    roleId,
    status
  }
  return request({
    url: '/system/role/changeStatus',
    method: 'put',
    data: data
  })
}

// 删除课程
export function delCourse(courseids) {
  return request({
    url: '/course/qf/course/' + courseids,
    method: 'delete'
  })
}

// 查询课程已授权用户列表
export function allocatedUserList(query) {
  return request({
    url: '/system/role/authUser/allocatedList',
    method: 'get',
    params: query
  })
}

// 查询课程未授权用户列表
export function unallocatedUserList(query) {
  return request({
    url: '/system/role/authUser/unallocatedList',
    method: 'get',
    params: query
  })
}

// 取消用户授权课程
export function authUserCancel(data) {
  return request({
    url: '/system/role/authUser/cancel',
    method: 'put',
    data: data
  })
}

// 批量取消用户授权课程
export function authUserCancelAll(data) {
  return request({
    url: '/system/role/authUser/cancelAll',
    method: 'put',
    params: data
  })
}

// 授权用户选择
export function authUserSelectAll(data) {
  return request({
    url: '/system/role/authUser/selectAll',
    method: 'put',
    params: data
  })
}

// 根据课程ID查询部门树结构
export function deptTreeSelect(roleId) {
  return request({
    url: '/system/role/deptTree/' + roleId,
    method: 'get'
  })
}
